<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>（我的岗位）学生个人现属岗位</title>
  <link rel="stylesheet" href="../../dist/css/layui.css">
</head>
<body>

<table id="demo" lay-filter="test"></table>




<script src="../../dist/layui.js"></script>
<script>
  layui.use(['layer', 'form'], function(){
    var layer = layui.layer
            ,form = layui.form;
  });

  layui.use('table', function(){
    var table = layui.table;

    //第一个实例
    table.render({
      elem: '#demo'
      ,height: "full-20"
      ,url: '/student/selectCurrentWork' //数据接口
      ,page: {
        limit: 10,
        limits: [5, 10]
      }
        ,cols: [[ //表头
        {field: 'dept', title: '隶属部门',align: "center", width:'15%', sort: true}
        ,{field: 'name', title: '岗位名称',align: "center", width:'15%'}
        ,{field: 'leader', title: '负责老师',align: "center", width:'15%'}
        ,{field: 'place', title: '工作地点',align: "center", width:'20%'}
        ,{field: 'salary', title: '工资',align: "center", width: '15%', sort: true}
        ,{field: 'operation', title: '操作',  width:'20%', align:'center', toolbar: '#barDemo'}
      ]]
    });
    // 操作选项
    table.on('tool(test)', function (obj) {

      // 本行数据
      var data = obj.data;
      switch (obj.event) {
        case "detail" :
          layer.open({
            title: '岗位详情',
            type:0,
            content:data.detail.toString(),
            icon: 6
          });
          break;
        case "workTime" :
          layer.open({
            title: '工作时间',
            type:0,
            content:parseWorkTime(data.workingTime.toString()),
            icon: 6
          });
          break;
      }
    });
  });
  // 解析工作时间
  function parseWorkTime(workTimeContext) {
    return workTimeContext.replaceAll('MON', '周一')
            .replaceAll('TUE', '周二')
            .replaceAll('WED', '周三')
            .replaceAll('THU', '周四')
            .replaceAll('FRI', '周五')
            .replaceAll('SAT', '周六')
            .replaceAll('SUN', '周日')
            .replaceAll(',', '，\n');
  }
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="detail">工作内容</a>
  <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="workTime">工作时间</a>
</script>
</body>
</html>
